<style scoped>
.addlist .activ {
  transform: rotate(180deg);
}
.addlist {
  width: 100%;
  border-top: 1px solid #242c40;
  position: relative;
}

.addlist p {
  height: 36px;
  line-height: 36px;
  margin: -1px auto 0;
  border-top: 1px solid #1e72ae;
  width: 154px;
  color: #1e72ae;
  cursor: pointer;
}
.addlist p img {
  margin-left: 5px;
}
.list-box {
  padding: 15px 0px 5px;
}
.list-box ul::-webkit-scrollbar{
  width: 0;
}
.list-box ul {
  display: flex;
  flex-wrap: wrap;
  width: 1140px;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  transition: all .15s;
}
.list-box ul li {
  width: 135px;
  margin-right: 10px;
  margin-bottom: 24px;
  cursor: pointer;
}
.list-box ul li:nth-child(8n) {
  margin-right: 0;
}
.list-box-anmite {
  background-image: url(../../assets/fight-list-bg.png);
  position: absolute;
  top: -15px;
  left: -15px;
  bottom: -15px;
  right: -15px;
  z-index: 1;
  background-size: 100% 100%;
}
.list-box ul li:hover .list-box-anmite {
  background-image: url(../../assets/fight-list-bgac.png);
  transform: rotate(90deg);
  transition: all 0.5s ease-out;
}
.list-box ul li:hover .list-box-item {
  /* background-position: 5px 5px;
     margin-top: -40px; */
  /* top: 40%;
    left: 50%;
    transition: 0.5s;
    transform: translate(-50%, 0%) rotate(-5deg); */
}
.list-box-item {
  position: absolute;
  z-index: 9;
  bottom: -6px;
  left: 50%;
  width: 48px;
  height: 28px;
  margin-left: -24px;
  background-image: url(../../assets/machine-icon1.png);
  background-size: 100% 100%;
}
.list-box-box {
  position: absolute;
  width: 76px;
  height: 76px;
  top: 50%;
  margin-top: -38px;
  left: 50%;
  margin-left: -38px;
  z-index: 6;
  border-radius: 50%;
  border: 2px solid #1e72ae;
  box-sizing: border-box;
  overflow: hidden;
}
.list-box-box img {
  width: 100%;
  height: 100%;
}
.list-box ul {
  display: flex;
  /* justify-content: space-between; */
  flex-wrap: wrap;
  min-height: 250px;
}

.list-box ul li:nth-child(4n) {
  margin-right: 0px;
}
.list-box ul li > div:first-child {
  width: 135px;
  height: 135px;
  position: relative;
  margin: 0 auto 8px;
}

.list-box ul li > div:last-child {
  margin: 15px auto;
  width: 110px;
}
.list-box ul li > div:last-child > div:first-child {
  width: 97px;
  height: 27px;
  /* background-image: url(../../assets/hbb-btn-bgs.png);
    background-size: 100% 100%; */
  margin: 0 auto;
  line-height: 27px;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
/*  .list-box ul li:hover>div:last-child>div:first-child{
    background-image: url(../../assets/hbb-btn-bg.png);
  } */
.list-box ul li > div:last-child > div:nth-child(2) {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 2px auto;
  font-size: 12px;
  color: #ffa32a;
  line-height: 12px;
}
.list-box ul li > div:last-child > div:nth-child(2) img {
  width: 12px;
  height: 12px;
}
.list-box ul li > div:last-child > div:nth-child(2) p {
  margin-left: 5px;
}
.list-box ul li > div:last-child > div:nth-child(3) {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  color: #6cbcff;
  font-size: 12px;
  line-height: 12px;
}

.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
.content {
  width: 1200px;
  background: #2b3242;
  margin: 83px auto 10px;
  padding-bottom: 10px;
  transition: all 0.5s;
  transform: scale(0);
}
.showcontent {
  transform: scale(1);
}
.title {
  height: 54px;
  padding: 0 22px;
  font-size: 22px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.close {
  font-size: 40px;
  cursor: pointer;
}
.table-box {
  background: #191e2b;
  padding: 0 9px;
  text-align: center;
  font-size: 14px;
  color: #909fbb;
}
.table-row {
  display: flex;
  align-items: center;
  min-height: 53px;
}
.table-row:nth-child(2n) {
  background: #13181e;
}
.table-row:nth-child(2n - 1) {
  background: #0b0c10;
}
.table-row p {
  flex: 1;
}
.table-title {
  font-size: 16px;
  background: #222833 !important;
  color: #909fbb;
}
.page-box {
  padding: 24px 0;
}
.avatar{
  width: 34px;
  margin: 0 2px;
}
.gong{
  width: 40PX;
}
.money{
  display: flex;
  align-items: center;
  color: #FFA32A;
  text-align: center;
}
.money img{
  width: 13px;
  margin-right: 8px;
}

.list-box{
    background: #191E2B;
    display: flex;
    flex-flow: wrap;
    padding-top: 16px;
  }
  .data-item{
    width: 20%;
    padding: 0 16px 24px;
    font-size: 14px;
    text-align: left;
    color: #fff;
    padding-left: 15px;
    box-sizing: border-box;
  }
  .data-bg{
    height: 151px;
    background: url(../../assets/color03.png);
    background-size: 100% 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .gong{
    width: 95%;
  }
  .money{
    margin: 9px 0 5px 0;
    display: flex;
    align-items: center;
    color: #FFA32A
  }
  .money-ico{
    width: 15px;
    margin-right: 5px;
  }
  .switch{
    position: absolute;
    right: 16px;
    top: 0;
    height: 33px;
    width: 110px;
    background: #0D71C3;
    color: #fff;
    line-height: 33px;
    font-size: 12px;
    box-sizing: border-box;
    padding-left: 10px;
    border-radius: 15.5px;
    cursor: pointer;
    text-align: left;
  }
  .inner{
    position: absolute;
    right: 0;
    top: 0;
    height: 33px;
    border-radius: 15.5px;
    background: #0D71C3;
    width: 33px;
    text-align: right;
    padding-right: 20px;
    box-sizing: border-box;
    overflow: hidden;
    transition: all .15s;
  }
  .ball{
    width: 33px;
    height: 33px;
    position: absolute;
    left: 0;
    top: 0;
    background: #fff;
    border-radius: 50%;
  }
  .showrobat{
    width: 110px;
  }
  .nobg{
    background: none;
  }
  .name:first-child{
    width: 97px;
    height: 27px;
    background-image: url(../../assets/hbb-btn-bgs.png);
    background-size: 100% 100%;
    margin:  0 auto;
    line-height: 27px;
    color: #FFFFFF;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }
  .list-box ul li:hover>div:last-child>div:first-child{
    background-image: url(../../assets/hbb-btn-bg.png);
  }
  .name:last-child{
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px auto;
    font-size: 12px;
    color: #FFA32A;
  }
  .name:last-child img{
    width: 12px;
    height: 12px;
  }
  .name:last-child p{
    margin-left: 5px;
  }
  .name{
    margin-bottom: 10px !important;
  }
  .gunbox{
    width: 94px;
    height: 86px;
    background: url(../../assets/hbb-list-box.png);
    background-size: 100% 100%;
    position: relative;
    top: 28px;
    left: 25px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-around;
  }
  .guns{
    width: 110%;
  }
</style>

<template>
  <div class="list-box">
    <ul v-if="showrobat" :style="{ height: activ == 0 ? '150px' : '500px' }">
      <li v-for="(robot, index) in robotList" :key="index" @click="openDetail(index)">
        <div>
          <div class="list-box-anmite"></div>
          <div class="list-box-box">
            <img :src="robot.image"/>
          </div>
          <div class="list-box-item"></div>
        </div>
        <div>
          <div>{{robot.name}}</div>
          <div>
            <div>
              <img src="../../assets/money-icon.png" />
            </div>
            <p>{{robot.money}}</p>
          </div>
          <div>
            <img src="../../assets/huangguan-icon.png" />
            <span>{{robot.victory}}/{{robot.total}}</span>
          </div>
        </div>
      </li>
    </ul>
    <ul v-else :style="{ height: activ == 0 ? '150px' : '400px' }">
      <li v-for="(gun, index) in fightBoxList" @click="openGunDetail(index)" :key="index">
        <div>
          <div class="list-box-anmite"></div>
          <div class="gunbox" :style="{ backgroundImage: `url(${gun.backgroundImage})` }">
            <img class="guns" :src="gun.boxSkinList[0].skinDetails.image" alt="">
          </div>
          <div class="list-box-item nobg"></div>
        </div>
        <div>
          <div class="name">{{gun.name}}</div>
          <div>
            <div>
              <img src="../../assets/money-icon.png" />
            </div>
            <p>{{gun.boxSkinList[0].skinDetails.price}}</p>
          </div>
        </div>
      </li>
    </ul>
    <div class="addlist">
      <p @click="addlist(1)" v-if="activ == 0">
        展开
        <img src="../../assets/direction-icon1.png" />
      </p>
      <p @click="addlist(0)" v-else>
        收起
        <img class="activ" src="../../assets/direction-icon1.png" />
      </p>
      <div class="switch" @click="showrobat = !showrobat">查看机器人  
        <div :class="['inner', { showrobat }]">
          <div class="ball"></div>
          查看箱子
        </div>
      </div>
    </div>
    <div class="popup" :style="{width: detailModalWidth}">
      <div :class="['content', { showcontent: detailModal }]">
        <div class="title">
          <p>势如破竹</p>
          <p class="close" @click="detailModal = false">×</p>
        </div>
        <div class="table-row table-title">
          <p>结束时间</p>
          <p>房间号</p>
          <p>玩家</p>
          <p>盲盒信息</p>
          <p>总额</p>
          <p>状态</p>
        </div>
        <div class="table-box">
          <div class="table-row" v-for="i in 10" :key="i">
            <p>2021-10-03 00:14:57</p>
            <p>000000000000000000000000</p>
            <p>
              <img class="avatar" src="../../assets/hedar-icon1.png" alt />
            </p>
            <p>
              <img class="gong" src="../../assets/fightpk-hedar-list.png" alt />
            </p>
            <p class='money'>
              <img src="../../assets/money-icon.png" alt />0.00
            </p>
            <p>已结束</p>
          </div>
          <div class="page-box">
            <v-pagination
              :total="total"
              :display="display"
              :current-page="current"
              @pagechange="pagechange"
            ></v-pagination>
          </div>
        </div>
      </div>
    </div>
    <div class="popup" :style="{width: gunDetailModalWidth}">
      <div :class="['content', { showcontent: gunDetailModal }]">
        <div class="title" v-if="fightBoxList[currentFightIndex]">
          <p>{{fightBoxList[currentFightIndex].name}}</p>
          <p class="close" @click="gunDetailModal = false">×</p>
        </div>
        <div class="list-box" v-if="fightBoxList[currentFightIndex]">
          <div v-for="skin in fightBoxList[currentFightIndex].boxSkinList" :key="skin.id" class="data-item">
            <div class="data-bg" :style="{ backgroundImage: `url(${levalMap[skin.skinDetails.rarity]})` }">
              <img class="gong" :src="skin.skinDetails.image" alt="">
            </div>
            <p class="money"><img class="money-ico" src="../../assets/money-icon.png" alt="">{{skin.skinDetails.price}}</p>
            <p>{{skin.skinDetails.skinName}}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import pagination from '../pagination.vue'
export default {
  props: {
    robotList: {
      type: Array,
      default: []
    },
    fightBoxList: {
      type: Array,
      default: []
    }
  },
  components: {
    'v-pagination': pagination
  },
  data() {
    return {
      levalMap: {
        '工业级': require('../../assets/color01.png'),
        '消费级': require('../../assets/color01.png'),
        '普通级': require('../../assets/color01.png'),
        '军规级': require('../../assets/color01.png'),
        '高级': require('../../assets/color01.png'),
        '保密': require('../../assets/color01.png'),
        '受限': require('../../assets/color02.png'),
        '非凡': require('../../assets/color03.png'),
        '隐秘': require('../../assets/color04.png'),
        '违禁': require('../../assets/color05.png')
      },
      activ: 0,
      detailModal: false,
      showrobat: true,
      gunDetailModal: false,
      currentRobotIndex: 0,
      currentFightIndex: 0,
      total: 0,
      display: 10,
      detailModalWidth: 0,
      gunDetailModalWidth: 0,
      current: 1
    }
  },
  watch: {
    detailModal(newVal) {
      if (newVal) {
        this.detailModalWidth = '100vw'
      } else {
        setTimeout(() => {
          this.detailModalWidth = 0
        }, 500);
      }
    },
    gunDetailModal(newVal) {
      if (newVal) {
        this.gunDetailModalWidth = '100vw'
      } else {
        setTimeout(() => {
          this.gunDetailModalWidth = 0
        }, 500);
      }
    }
  },
  methods: {
    openGunDetail(index) {
      this.currentFightIndex = index
      this.gunDetailModal = true
    },
    openDetail(index) {
      this.currentRobotIndex = index
      this.detailModal = true
    },
    addlist(e) {
      this.activ = e
    },
    pagechange(page) {
      this.current = page
    }, 
  },
  created() {

  }
}
</script>